home *** CD-ROM | disk | FTP | other *** search
-
- #include "CPoint.h"
-
- #include "CRect.h"
-
- void CPoint::ConstrainTo(const CRect& rect)
- {
- if (X() > rect.Right())
- fPoint.h = rect.Right();
- else if (X() < rect.Left())
- fPoint.h = rect.Left();
-
- if (Y() > rect.Bottom())
- fPoint.v = rect.Bottom();
- else if (Y() < rect.Top())
- fPoint.v = rect.Top();
- }
-
-
- CPoint CPoint::operator+(const CPoint& pt) const
- {
- return CPoint(X() + pt.X(), Y() + pt.Y());
- }
-
-
- CPoint CPoint::operator-(const CPoint& pt) const
- {
- return CPoint(X() - pt.X(), Y() - pt.Y());
- }
-
-
- CPoint& CPoint::operator+=(const CPoint& pt)
- {
- fPoint.h += pt.X();
- fPoint.v += pt.Y();
- return *this;
- }
-
-
- CPoint& CPoint::operator-=(const CPoint& pt)
- {
- fPoint.h -= pt.X();
- fPoint.v -= pt.Y();
- return *this;
- }
-
-
-
- Boolean CPoint::operator!=(const CPoint& pt) const
- {
- return (X() != pt.X()) || (Y() != pt.Y());
- }
-
-
- Boolean CPoint::operator==(const CPoint& pt) const
- {
- return (X() == pt.X()) && (Y() == pt.Y());
- }
-
-
-